/**
 * 
 */
package denaris.core;

import denaris.core.controller.AbstractController;
import denaris.core.entity.AbstractEntity;
import denaris.midlet.GameScreen;

/**
 * @author stkl23
 *
 */
public class LaserEmitter extends BulletEmitter {
	public class LaserController extends AbstractController{
		public boolean advance() {
			controllable.move(getDeltaX(), getDeltaY());
			if (isInScope(controllable.getX(), controllable.getY())) {
				return true;
			}else {
				return false;
			}
		}
	}
	
	public LaserEmitter(int cacheSize, int dx, int dy, String bulletImgPath, int bulletWidth, int bulletHeight) {
		super(cacheSize, dx, dy, bulletImgPath, bulletWidth, bulletHeight);
	}

	/* (non-Javadoc)
	 * @see denaris.core.BulletEmitter#collidesWith(denaris.core.AbstractParticle, denaris.core.entity.AbstractEntity)
	 */
	public boolean collidesWith(AbstractParticle particle, AbstractEntity entity) {
		return particle.getController().getSprite().collidesWith(entity.getController().getSprite(), false);
	}

	/* (non-Javadoc)
	 * @see denaris.core.BulletEmitter#createController()
	 */
	public AbstractController createController() {
		return new LaserController();
	}
	
	public void emitt(int x, int y) {
		super.emitt(x + GameScreen.nextPositiveInt(15), y + 1);
	}

	public boolean collidesWith(AbstractParticle particle, TiledMap map) {
		return particle.getController().getSprite().collidesWith(map.getLayer(), false);
	}

}
